import Taro from "@tarojs/taro";
import global from '../global/index';
// const HOST_URL = 'http://192.168.1.5:8081';
// const HOST_URL = 'http://uw2uz7.natappfree.cc';
const HOST_URL = 'https://api.yyysgg.com.cn/prod-api';
const IMAGE_URL = 'https://api.yyysgg.com.cn';

// const HOST_URL = 'https://asher-api.mynatapp.cc/prod-api';
// const IMAGE_URL = 'https://asher-api.mynatapp.cc';

// const IMAGE_URL = 'http://192.168.1.5:8081';

const request = (method, url, data, success, fail, complete) => {
  return Taro.request({
    method,
    url: HOST_URL + url, //仅为示例，并非真实的接口地址
    data,
    header: {
      'content-type': 'application/json', // 默认值,
      'Authorization': global.token
    },
    success,
    fail,
    complete
  })
}


export default {
  get: (url, data, success, fail, complete) => request('GET', url, {}, success, fail, complete),
  post: (url, data, success, fail, complete) => request('POST', url, data, success, fail, complete),
  put: (url, data, success, fail, complete) => request('PUT', url, data, success, fail, complete),
  delete: (url, data, success, fail, complete) => request('DELETE', url, data, success, fail, complete),
  imgHost: IMAGE_URL,
  host: HOST_URL
}
